<?php
// src/Pyaf/GymBundle/Repository/RutinaRepository.php
namespace Pyaf\GymBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Description of RutinaRepository
 *
 * @author Toshiba P755-S5272
 */
class RutinaRepository extends EntityRepository{
    
    public function findAllOrderByNombre() {                
        return $this->getEntityManager()
                    ->createQuery('SELECT r FROM PyafGymBundle:Rutina r ORDER BY r.nombre ASC')
                    ->getResult();
    }
    
    public function findRutina($id) {                
        return $this->getEntityManager()
                    ->createQuery("SELECT r FROM PyafGymBundle:Rutina r WHERE r.id = $id")
                    ->getOneOrNullResult();
    }
    
    public function save($rutina){
        $this->saveRutina($rutina);
    }
    
    public function saveRutina($rutina) {
        $em = $this->getEntityManager();
        $em->persist($rutina);
        $em->flush();
    }
}

?>
